<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id = "app">
        {{msg}}
        <div id="header">
            <h1>首页</h1>
        </div>
        <div id="nav">
            <router-link to="/reg">用户注册</router-link>
            <router-link to="/login">用户登录</router-link>
        </div>
       
        <div id="main">
            <router-view></router-view>
        </div>
     
    
    </div>

    <!-- 1.创建组件模板 -->
    <template id="login">
        <ul>
            <li>用户登录</li>
            <li><input type="text" name="usesrname" placeholder="请输入用户名"><br></li>
            <li> <input type="password" name="password" placeholder="请输入密码"></li>
            <li><button>登录</button></li></li>
        </ul>
        
    </template>
    <template id="reg">
        <ul>
            <li>用户注册</li>
            <li><input type="text" name="usesrname" placeholder="请输入用户名"><br></li>
            <li> <input type="password" name="password" placeholder="请输入密码"></li>
            <li> <input type="password" name="password" placeholder="再次输入"></li>
            <li><button>注册</button></li></li>
        </ul>
        
    </template>

    <script src="./node_modules/vue/dist/vue.js"></script>
    <!-- 3.引入我们的vue-router -->
    <script src="./node_modules/vue-router/dist/vue-router.js"></script>

    <script>

        // 2.创建组件
        const login = {
            template:"#login"
        }

        const reg = {
            template:"#reg"
        }

        // 4.配置路由
        const router = new VueRouter({
            routes:[
                // 路由的路径             组件
                { path: '/reg', component: reg },
                { path: '/login', component: login }

        
            ]
        });

       
        const vm  = new Vue({
            el:"#app",
            data:{
                msg:"吃货联盟"
            },
            //把router放入我们的vue实例
            router
           
        })



    </script>
</body>
</html>